package main.java;

import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GetConfig {

    @RequestMapping(value = "get")
    public String getConfig() throws Exception {
        Watcher watcher = (event) -> System.out.println("ceshi");
        ZooKeeper zooKeeper = new ZooKeeper("tjwqstaging.zk.hadoop.srv:2181", 300, watcher);
        byte[] data = zooKeeper.getData("/", watcher, null);
        zooKeeper.close();
        String value = new String(data);
        System.out.println(value);
        return value;
    }
}
